package com.md.model.page;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 2021-10-20 22:20
 *
 * @author 刘骄阳
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageRequest {
  /**
   * 默认的行数
   */
  public static final Long DEFAULT_PAGE_SIZE = 10L;
  /**
   * 行数
   */
  private Long pageSize;
  /**
   * 页码
   */
  private Long pageNum;

  public Long getPageSize() {
    if (pageSize == null || pageSize <= 0) {
      return DEFAULT_PAGE_SIZE;
    } else {
      return this.pageSize;
    }
  }

  public void setPageSize(final Long pageSize) {
    if (pageSize == null || pageSize <= 0) {
      this.pageSize = DEFAULT_PAGE_SIZE;
    } else {
      this.pageSize = pageSize;
    }
  }

  public Long getPageNum() {
    if (pageNum == null || pageNum < 1) {
      return 1L;
    } else {
      return this.pageNum;
    }
  }

  public void setPageNum(final Long pageNum) {
    if (pageNum == null || pageNum < 1) {
      this.pageNum = 1L;
    } else {
      this.pageNum = pageNum;
    }
  }
}
